<?php

namespace App\Service\AppStore;

use App\Helpers\AliyunUtil;
use App\Model\UserProfile;
use App\Service\BaseService;

/**
 * 分类用户列表
 */
class RecUserService extends BaseService
{
    public function handle()
    {
        $userId = $this->getUserId();
        //分类ID
        $cateId = $this->request->input('catagory_id', 1);
        $where = [
            ['avatar', '<>', ''],
            ['is_official', 1]
        ];
        $data = UserProfile::where($where)->inRandomOrder()->limit(3)->get()->toArray();
        $ret['list'] = [];
        array_walk($data, function ($user) use (&$ret) {
            $ret['list'][] = [
                'user_id' => $user['user_id'],
                'is_follow' => 0,
                'nick_name' => $user['nick_name'],
                'avatar' => AliyunUtil::IMG_HOST . $user['avatar'],
            ];
        });
        return $ret;
    }
}
